﻿using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;
using Wips.Domain.Models;

namespace Wips.AppService.Publisher.PublishFlows.Requests
{
    /// <summary>
    /// 保存节点数据
    /// </summary>
    public class SavePublishFlowNodeRequest : IRequest<string>, ITxRequest
    {
        /// <summary>
        /// 归属流程任务
        /// </summary>
        public string PublishFlowId { get; set; } = "";


        /// <summary>
        /// 节点类型
        /// </summary>
        public EnumNodeType NodeType { get; set; }


        /// <summary>
        /// 节点结果值
        /// </summary>
        public string Result { get; set; } = "";

    }

    /// <summary>
    /// 校验
    /// </summary>
    public class SavePublishFlowNodeRequestValidator : AbstractValidator<SavePublishFlowNodeRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public SavePublishFlowNodeRequestValidator()
        {
            RuleFor(p => p.PublishFlowId)
                .Must(p => !string.IsNullOrEmpty(p))
                .WithMessage("PublishFlowId不能为空");


            RuleFor(p => p.Result)
               .Must(p => !string.IsNullOrEmpty(p))
               .WithMessage("Result不能为空");


        }
    }
}
